package com.example.everying.config;/*
 * 项目名称: everything
 * 文件名: RequestLoggingFilterConfig
 * 作者: 张泽阳
 * 日期: 2025/6/4
 * 描述: 请求日志过滤器
 */

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.CommonsRequestLoggingFilter;

@Configuration
public class RequestLoggingFilterConfig {

    @Bean
    public CommonsRequestLoggingFilter requestLoggingFilter() {
        CommonsRequestLoggingFilter filter = new CommonsRequestLoggingFilter();
        filter.setIncludeQueryString(true);     // 记录查询参数
        filter.setIncludePayload(true);         // 记录请求体
        filter.setMaxPayloadLength(10000);      // 请求体最大长度
        filter.setIncludeHeaders(true);         // 记录请求头
        filter.setAfterMessagePrefix("HTTP  REQUEST: ");  // 日志前缀
        return filter;
    }
}
